package server

import (
	"gitee.com/enjoy_5/integral-rpc/internal/model"
	"gitee.com/enjoy_5/integral-rpc/proto/integral"
)

// 积分表 model转pb
func IntegralModelToPb(in *model.Integral) *integral.IntegralInfo {
	return &integral.IntegralInfo{
		Id:            int64(in.ID),
		UserId:        in.UserId,
		PointsBalance: in.PointsBalance,
	}
}

// 积分详情
func GetIntegralInfoByUserId(userId int64) (*integral.IntegralInfo, error) {
	m := new(model.Integral)
	info, err := m.GetIntegralInfo(userId)
	if err != nil {
		return nil, err
	}

	return IntegralModelToPb(info), nil
}
